Part Number Hot Search : 
1N4588R CY7C6372 ATP204SM HYB25 200MA P4SMA91A E000467 W2E3B
Product Description
Full Text Search
 

To Download AN1270 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  1/28 september 2001 AN1270 application note software drivers for the m58lw064a flash memory contents n introduction n the m58lw064a programming model n writing c code for the m58lw064a n c library functions provided n porting the drivers to the target system n limitations of the software n conclusion n revision history n c1270_16.h listing n c1270_16.c listing introduction this application note provides library source code in c for the m58lw064a multi-bit cell flash memory. the m58lw064a supports both asynchronous and synchronous burst bus inter- faces. the c code drivers work on a layer above the hardware and can be used successfully over either bus interface. listings of the source code can be found at the end of this doc- ument. the source code is also available in file form from the internet site http://www.st.com or from your stmicroelectronics distributor. the c1270_16.c and c1270_16.h files contain librar- ies for accessing the m58lw064a flash memories. also included in this application note is an overview of the pro- gramming model for the m58lw064a. this will familiarize the reader with the operation of the memory devices and provide a basis for understanding and modifying the accompanying source code. the source code is written to be as platform independent as possible and requires minimal changes by the user in order to compile and run. the application note explains how the user should modify the source code for their individual target hard- ware. all of the source code is backed up by comments explain- ing how it is used and why it has been written as it has. this application note does not replace the m58lw064a datasheet. it refers to the datasheet throughout and it is neces- sary to have a copy in order to follow some of the explanations. the software and accompanying documentation has been test- ed on a target platform. it is small in size and can be applied to any target hardware. the m58lw064a programming model the m58lw064a is a 64mb (4mb x16) flash memory which can be electrically erased and programmed through special coded command sequences on most standard microprocessor buses. the device is broken down into 64 blocks, each 64 kwords in size. each block can be erased individually. the m58lw064a is a smart voltage device. it differs from first generation dual voltage devices which require a 12v supply to program or erase. the m58lw064a is therefore easier to use since the hardware does not need to cater for special bus sig- nal levels. the voltages needed to erase the device are gener- ated by charge pumps inside the device. two power supply
AN1270 - application note 2/28 pins are used to give the optimal supply voltage conditions. in normal operation the core (v dd pin) is sup- plied with 3v and the i/o buffers (v ddq ) are supplied with 1.8v to 3v. unlike many other flash memories, the v pp program/erase enable pin is not a supply pin; instead it op- erates using logic levels. traditionally a jumper or a high power circuit was required to drive this type of pin. on the m58lw064a the pin can be driven directly from a logic buffer, enabling easy control of global block protection by the microprocessor. included in the device is a program/erase controller. with first generation flash memory devices the soft- ware had to manually program all of the words to 0000h before erasing to ffffh using special program- ming sequences. the program/erase controller in the m58lw064a allows a simpler programming model to be used, by taking care of all the necessary steps required to erase and program the memory. this has led to improved reliability so that in excess of 100,000 program/erase cycles are guaranteed per block on the device (150ns part). bus operations and commands most of the functionality of the m58lw064a is available via the two standard bus operations: read and write. read operations retrieve data or status information from the device. write operations are interpreted by the device as commands, which modify the data stored or the behavior of the device. only certain spe- cial sequences of write operations are recognized as commands by the m58lw064. the various com- mands recognized by the m58lw064 are listed in the instructions table of the datasheet; the main commands can be grouped as follows: 1. read 2. read electronic signature 3. erase 4. program (write to buffer and program) 5. program/erase suspend 6. common flash interface query 7. block protect/blocks unprotect 8. asynchronous/synchronous bus interface configuration. the read command returns the m58lw064a to read mode where it behaves as a rom. in this state, a read operation outputs onto the data bus the data stored at the specified address of the device. the read electronic signature command places the device in a mode which allows the user to read the electronic signature and block protection status of the device. the electronic signature (manufacturer and device codes) and the block protection status are accessed by reading different addresses while in the auto select mode. in the library of software drivers this mode is known as the auto select mode to make the m58lw064a compatible with the m29 series flash memories. the erase command is used to set all the bits to 1 in every memory location in the selected block. all data previously stored in the erased block will be lost. the erase command takes longer to execute than the other commands, because an entire block is erased at once. attempts to erase or program a block while the memory is protected (e.g. v pp = v il ) generate an error and do not modify the contents of the memory. the write to buffer and program command is used to modify the data stored at the specified addresses of the device. programming modifies one or more pages (4 words) at a time. unlike previous flash mem- ories, which are able to program each word or byte at a time, the m58lw064a must be programmed one page at a time. once any word within the page is programmed it is no longer possible to change it, or any other word within that page, until an erase command has been issued on the whole block. each write to buffer and program command can program up to 4 pages (16 words); programming larger amounts of
3/28 AN1270 - application note data must be performed one buffer at a time, by issuing a write to buffer and program command, waiting for the command to complete, then issuing the next write to buffer and program command, and so on. issuing the program/erase suspend command during a program or erase operation will temporarily place the m58lw064a in program/erase suspend mode. while an erase operation is being suspended the blocks not being erased may be read or programmed as if in the reset state of the device. while a program operation is being suspended the rest of the device may be read. this allows the user to access informa- tion stored in the device immediately rather than waiting until the program or erase operation completes, typically 192 m s for programming and 0.75s for erasing on the m58lw064a. the program or erase oper- ation is resumed when the device receives the program/erase resume command. the common flash interface query command of the device allows the user to identify the number of blocks and the addresses of the blocks in the flash. the interface also contains information relating to the typical and maximum program and erase durations. this allows the user to implement software timeouts instead of waiting indefinitely for a defective flash to finish programming or erasing. for further information about the cfi, please refer to the cfi specification available from the internet site (http://www.st.com) or from your stmicroelectronics distributor. blocks can be protected against accidental or malicious program and erase operations changing their contents. block protection on the m58lw064a is non-volatile; after power up or a hardware reset the block protection remains at the state it was in before the power-down or reset. each block can be protected in- dividually, or all blocks can be unprotected at the same time; it is not possible to unprotect one block, leav- ing any others protected. the bus configuration of the device can be changed. the device supports both asynchronous and syn- chronous bus operations, with many different options for burst synchronous reads and asynchronous page reads. note that some modes of the m58lw064a do not support synchronous read operations, when one of these modes is selected the part will automatically revert to asynchronous mode and return to synchronous mode afterwards. the status register while the m58lw064a is programming or erasing, a read from the device will output the status register of the program/erase controller. the status register, which can also be accessed by issuing the read status register command, provides valuable information about the most recent program or erase com- mand. the status register bits are described in the status register bits table of the m58lw064a datasheet. their main use is to determine when programming or erasing is complete and whether it is suc- cessful or not. completion of the program or erase operation is indicated by the program/erase controller status bit (status register bit dq7) becoming 1. programming or erasing errors are then indicated by one or more of the various error bits (status register bits dq1, dq3, dq4 and dq5) being 1. if a failure occurs the status register error bits will remain set until a clear status register command is issued to the device. this should be done before performing any further operations or it will not be possible to determine wheth- er the following operation resulted in an error or not. a detailed example the commands table of the m58lw064a datasheet describes the sequences of write operations that will be recognized by the program/erase controller as valid commands. for example programming 9465h to the address 03e2h requires the user to write the following sequence (in c): *(unsigned int*)(0x0000) = 0x00e8; /* 1st cycle (any block address) */ *(unsigned int*)(0x0000) = 0x0000; /* 2nd cycle: data length */ *(unsigned int*)(0x03e2) = 0x9465; /* 3rd cycle: address and data */ *(unsigned int*)(0x0000) = 0x00d0; /* final cycle: confirm and start */
AN1270 - application note 4/28 the first two addresses (0000h) are arbitrary, so long as they are inside the block where the data is to be programmed. this example assumes that address 0000h of the m58lw064a is mapped to address 0000h in the microprocessor address space. in practice it is likely that the flash will have a base offset which needs to be added to the address. while the device is programming the specified address, read operations will access the status register bits. status register bit dq7 will be 0 while programming is on-going and will become 1 on completion. if status register bits dq1, dq3 or dq4 are set on completion then the program command will have failed. following the programming, address 03e2h cannot be modified until an erase operation has been used to erase the block. furthermore it will not be possible to program any of the addresses in the range 03e0h to 03e3h until an erase operation has been used to erase the block; any attempt to do so will generate an error. writing c code for the m58lw064a the low-level functions (drivers) described in this application note have been provided to simplify the pro- cess of developing application code in c for the stmicroelectronics flash memories (m58lw064a). this enables users to concentrate on writing the high level functions required for their particular applications. these high level functions can access the flash memories by calling the low level drivers, hence keeping details of special command sequences away from the users' high level code: this will result in source code both simpler and easier to maintain. code developed using the drivers provided can be decomposed into three layers: 1. the hardware specific bus operations 2. the low-level drivers 3. the high level functions written by the user the implementation in c of the hardware specific read and write bus operations is required by the low- level drivers in order to communicate with the m58le064a. this implementation is hardware platform de- pendent as it is affected by which microprocessor the c code runs on and by where in the microproces- sor's address space the memory device is located. the user will have to write the c functions appropriate to his hardware platform (see flashread() and flashwrite() in the next section). the low-level drivers take care of issuing the correct sequences of write operations for each command and of interpreting the information received from the device during programming or erasing. these drivers encode all the specific details of how to issue commands and how to interpret the status register bits. the high level functions written by the user will access the memory device by calling the low-level func- tions. by keeping the specific details of how to access the m58lw064a away from the high level functions, the user is left with code which is simple and easier to maintain. it also makes the user's high level func- tions easier to apply to other stmicroelectronics flash memories. when developing an application, the user is advised to proceed as follows: C first write a simple program to test the low level drivers provided and verify that these operate as ex- pected on the user's target hardware and software environments. C then the user should write the high level code for his application, which will access the flash memories by calling the low level drivers provided. C finally test the complete application source code thoroughly. it should be noted that, if upgrading from a previous flash memory then all calls to the function flashpro- gram() in the application will have to be checked. previous flash were able to program each word/byte individually; this technique can no longer be used and it is necessary to program page by page.
5/28 AN1270 - application note c library functions provided the software library provided with this application note provides the user with source code for the following functions: flashreadreset() is used to reset the device into the read array mode. note that there should be no need to call this function under normal operation as all of the other software library functions leave the device in this mode. flashautoselect() is used to identify the manufacturer code, device code and version code of the device. the function uses the read electronic signature mode of the device. the function is called flashautoselect() to make it compatible with the m29 series flash memories. flashblockerase() is used to erase a block in the device. the blocks cannot be erased when v pp is low, v il : attempting to do so generates an error. flashchiperase() is used to erase the entire chip. the chip cannot be erased when v pp is low, v il : attempting to do so generates an error. flashprogram() is used to program data arrays into the flash. only previously erased double words can be programmed reliably. again, programming cannot take place when v pp low, v il . flashblockprotect() is used to protect a block in the flash. once protected, the data in the block cannot be programmed or erased until the block is unprotected. flashchipunprotect() is used to unprotect all the blocks in the flash memory. once unprotected, all the data in all the blocks can be erased or programmed. flashsetburstconfig() is used to change the bus configuration and select asynchronous or synchro- nous modes. to help the programmer select the correct settings, the header file contains many bit defini- tions that can be used. the functions provided in the software library rely on the user implementing the hardware specific bus op- erations. this is to be done by writing two functions as follows: C flashread() must be written to read a value from the flash. C flashwrite() must be written to write a value to the flash. an example of these functions is provided in the source code. in many instances these functions can be written as macros and therefore will not incur the function call time overhead. the two functions which perform the basic i/o to the device have been provided for users who have awkward systems. for example where the addressing system is peculiar or the data bus has d0..d15 of the device on d16..d31 of the microprocessor. they allow any user to quickly adapt the code to virtually any target system. throughout the functions assumptions have been made on the data types. these are: a char is 8 bits (1 byte). this is not the case in all microcontrollers. where it is not it will be necessary to mask the unused bits of the word. an int is 16 bits (2 bytes). again, like the char , if this is not the case it will be necessary to use a variable type which is 16 bits or longer and mask bits above 16 bits (particularly in the users flashread() func- tion). a long is 32 bits (4 bytes). it is necessary to have arithmetic greater than 16 bits in order to address the entire device. two approaches to the addressing are available: the desired address in the flash can be specified by a 32 bit linear pointer or a 32 bit offset into the device could be provided by the user. the flashread() functions in each case would declared as: unsigned long flashread( unsigned long *addr); unsigned long flashread( unsigned long uloff);
AN1270 - application note 6/28 the pointer option has the advantage that it runs faster. the 32 bit offset needs to be changed to an ad- dress for each access and this involves 32 bit arithmetic. using a 32 bit offset is, however, more portable since the resulting software can easily be changed to run on microprocessors with segmented memory spaces (such as the 8086). for maximum portability all the functions in this application note use a 32 bit unsigned long offset, rather than a pointer. porting the drivers to the target system before using the software in the target system the user needs to write flashread() and flash- write() functions appropriate to the target hardware. the example flashread() and flash- write() functions provided in the source code should give the user a good idea of what is required and can be used in many instances without much modification. to test the source code in the target system start by simply reading from the m58lw064a. if it is erased then only ffffh data should be read. next read the manufacturer and device codes and check they are correct. if these functions work then it is likely that all of the functions will work but they should all be tested thoroughly. the programmer needs to take extra care when the device is accessed during an interrupt service routine. two situations exist which must be considered: when the device is in read mode interrupts can freely read from the device. interrupts which do not access the device may be used during all the functions. the programmer should also take care when a reset is applied during program or erase operations. the flash will be left in an indeterminate state and data could be lost. limitations of the software the software provided does not implement a full set of the m58lw064a's functionality. it is left to the user to implement the program/erase suspend command of the device. the standby mode is a hardware fea- ture of the device and cannot be controlled through software. care should be taken in some of the while() loops. no time-outs have been implemented. software ex- ecution may stop in one of the loops due to a hardware error. a /* timeout! */ comment has been put at these places and the user can add a timer to them to prevent the software failing. the software only caters for one device in the system. to add software for more devices a mechanism for selecting the devices will be required. when an error occurs the software simply returns the error message. it is left to the user to decide what to do. either the command can be tried again or, if necessary the device may need to be replaced. conclusion the m58lw064a 3v flash memory is an ideal product for 16 bit embedded and other computer systems, able to be easily interfaced to microprocessors and driven with simple software drivers written in the c language. revision history date revision details july 2001 first issue september 2001 tested using new silicon
7/28 AN1270 - application note /**** c1270_16.h header file for flash memory ********************************** filename: c1270_16.h description: header file for c1270_16.c. consult the c file for details. copyright (c) 2001 stmicroelectronics. this program is provided as is without warranty of any kind,either expressed or implied, including but not limited to, the implied warranty of merchantability and fitness for a particular purpose. the entire risk as to the quality and performance of the program is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction. *******************************************************************************/ /******************************************************************************* commands for the various functions *******************************************************************************/ /* read signature values */ #define flash_read_manufacturer (-1) #define flash_read_device_code (-2) /******************************************************************************* error conditions and return values. see end of c file for explanations and help *******************************************************************************/ #define flash_block_protected (0x0001) #define flash_block_unprotected (0x0000) #define flash_success (-1) #define flash_block_invalid (-5) #define flash_program_fail (-6) #define flash_offset_out_of_range (-7) #define flash_wrong_type (-8) #define flash_block_failed_erase (-9) #define flash_unprotected (-10) #define flash_protected (-11) #define flash_vpp_invalid (-13) #define flash_erase_fail (-14) #define flash_unprotect_fail (-16) #define flash_protect_fail (-18) #define flash_cfi_fail (-22) #define flash_config_invalid (-23) /******************************************************************************* flash burst configuration definitions *******************************************************************************/ /* burst configuration register read mode */ #define flash_bcr_synchronous 0x00000000l #define flash_bcr_asynchronous 0x00008000l /* burst configuration register x-latency */ #define flash_bcr_xlat_7 0x00001000l #define flash_bcr_xlat_8 0x00001800l #define flash_bcr_xlat_9 0x00002000l #define flash_bcr_xlat_10 0x00002800l #define flash_bcr_xlat_11 0x00003000l #define flash_bcr_xlat_12 0x00004800l #define flash_bcr_xlat_13 0x00005000l
AN1270 - application note 8/28 #define flash_bcr_xlat_15 0x00006800l /* burst configuration register y-latency */ #define flash_bcr_ylat_1 0x00000000l #define flash_bcr_ylat_2 0x00000200l /* burst configuration register valid data ready timing */ #define flash_bcr_dr_normal 0x00000000l #define flash_bcr_dr_advance 0x00000100l /* burst configuration register burst type */ #define flash_bcr_interleave 0x00000000l #define flash_bcr_sequential 0x00000080l /* burst configuration register valid clock edge */ #define flash_bcr_clk_falling 0x00000000l #define flash_bcr_clk_rising 0x00000040l /* burst configuration register latch enable activation */ #define flash_bcr_l_disabled 0x00000000l #define flash_bcr_l_enabled 0x00000008l /* burst configuration register burst length */ #define flash_bcr_length_1 0x00000004l #define flash_bcr_length_2 0x00000005l #define flash_bcr_length_4 0x00000001l #define flash_bcr_length_8 0x00000002l #define flash_bcr_continuous 0x00000007l /******************************************************************************* function prototypes *******************************************************************************/ extern unsigned int flashread( unsigned long uloff ); extern void flashreadreset( void ); extern int flashautoselect( int ifunc ); extern int flashreadcfi( int icfifunc, unsigned int *ucfivalue ); extern int flashblockerase( unsigned char ucblock ); extern int flashchiperase( int *iresults ); extern int flashprogram( unsigned long uloff, size_t numwords, void *array ); extern int flashblockprotect( unsigned char ucblock ); extern int flashchipunprotect( void ); extern int flashsetburstconfig( unsigned long ulburstconfig ); extern char *flasherrorstr( int ierrnum );
9/28 AN1270 - application note /**** c1270_16.c m58lw064 flash memory driver ********************************* filename: c1270_16.c description: library routines for the m58lw064 64mb (4mb x16) flash memory. 16 bit drivers. version: 1.02 date: 07/09/2001 author: tim webster & alex nairac, oxford technical solutions copyright (c) 2001 stmicroelectronics. this program is provided as is without warranty of any kind, either expressed or implied, including but not limited to, the implied warranty of merchantability and fitness for a particular purpose. the entire risk as to the quality and performance of the program is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction. ******************************************************************************** version history. ver. date comments 1.00 13/06/2001 initial release of the software (untested). 1.01 22/06/2001 most functions tested on m58lw064a. functions flashblockunprotect(), flashchipprotect() and flashsetburstconfig() not yet tested. 1.02 07/09/2001 re-test using final silicon version. all functions ok. ******************************************************************************** this source file provides library c code for using the m58lw064 devices. the following devices are supported in the code: m58lw064a this file is used to access the devices in 16-bit mode only. the following functions are available in this library: flashreadreset() to reset the flash for normal memory access flashautoselect() to get information about the device flashreadcfi() to read cfi information from the flash flashblockerase() to erase a single block flashchiperase() to erase the whole chip flashprogram() to program a word or an array flashblockprotect() to protect a block of the memory flashchipunprotect() to unprotect the whole memory flashsetburstconfig() to set the burst configuration register flasherrorstr() to return the error string of an error for further information consult the data sheet and the application note. the application note gives information about how to modify this code for a specific application. the hardware specific functions which need to be modified by the user are: flashwrite() for writing a word to the flash flashread() for reading a word from the flash
AN1270 - application note 10/28 a list of the error conditions is at the end of the code. there are no timeouts implemented in the loops in the code. at each point where an infinite loop is implemented a comment /# timeout! #/ has been placed. it is up to the user to implement these to avoid the code hanging instead of timing out. the source code assumes that the compiler implements the numerical types as unsigned char 8 bits unsigned int 16 bits unsigned long 32 bits additional changes to the code will be necessary if these are not correct. *******************************************************************************/ #include #include c1270_16.h /* header file with global prototypes */ #define use_m58lw064a /******************************************************************************* constants *******************************************************************************/ #define manufacturer_st (0x0020) /* st manufacturer code is 0x20 */ #define base_addr ((volatile unsigned int*)0x00000000l) /* base_addr is the base address of the flash, see the functions flashread and flashwrite(). some applications which require a more complicated flashread() or flashwrite() may not use base_addr */ #define any_addr (0x00000000l) /* any address offset within the flash memory will do */ #ifdef use_m58lw064a #define expected_device (0x0017) /* device code for the m58lw064a */ #define flash_size (0x00400000l) /* total device size */ static const unsigned long blockoffset[] = { 0x00000000l, /* start offset of block 0 */ 0x00010000l, /* start offset of block 1 */ 0x00020000l, /* start offset of block 2 */ 0x00030000l, /* start offset of block 3 */ 0x00040000l, /* start offset of block 4 */ 0x00050000l, /* start offset of block 5 */ 0x00060000l, /* start offset of block 6 */ 0x00070000l, /* start offset of block 7 */ 0x00080000l, /* start offset of block 8 */ 0x00090000l, /* start offset of block 9 */ 0x000a0000l, /* start offset of block 10 */ 0x000b0000l, /* start offset of block 11 */ 0x000c0000l, /* start offset of block 12 */ 0x000d0000l, /* start offset of block 13 */ 0x000e0000l, /* start offset of block 14 */ 0x000f0000l, /* start offset of block 15 */ 0x00100000l, /* start offset of block 16 */ 0x00110000l, /* start offset of block 17 */ 0x00120000l, /* start offset of block 18 */
11/28 AN1270 - application note 0x00130000l, /* start offset of block 19 */ 0x00140000l, /* start offset of block 20 */ 0x00150000l, /* start offset of block 21 */ 0x00160000l, /* start offset of block 22 */ 0x00170000l, /* start offset of block 23 */ 0x00180000l, /* start offset of block 24 */ 0x00190000l, /* start offset of block 25 */ 0x001a0000l, /* start offset of block 26 */ 0x001b0000l, /* start offset of block 27 */ 0x001c0000l, /* start offset of block 28 */ 0x001d0000l, /* start offset of block 29 */ 0x001e0000l, /* start offset of block 30 */ 0x001f0000l, /* start offset of block 31 */ 0x00200000l, /* start offset of block 32 */ 0x00210000l, /* start offset of block 33 */ 0x00220000l, /* start offset of block 34 */ 0x00230000l, /* start offset of block 35 */ 0x00240000l, /* start offset of block 36 */ 0x00250000l, /* start offset of block 37 */ 0x00260000l, /* start offset of block 38 */ 0x00270000l, /* start offset of block 39 */ 0x00280000l, /* start offset of block 40 */ 0x00290000l, /* start offset of block 41 */ 0x002a0000l, /* start offset of block 42 */ 0x002b0000l, /* start offset of block 43 */ 0x002c0000l, /* start offset of block 44 */ 0x002d0000l, /* start offset of block 45 */ 0x002e0000l, /* start offset of block 46 */ 0x002f0000l, /* start offset of block 47 */ 0x00300000l, /* start offset of block 48 */ 0x00310000l, /* start offset of block 49 */ 0x00320000l, /* start offset of block 50 */ 0x00330000l, /* start offset of block 51 */ 0x00340000l, /* start offset of block 52 */ 0x00350000l, /* start offset of block 53 */ 0x00360000l, /* start offset of block 54 */ 0x00370000l, /* start offset of block 55 */ 0x00380000l, /* start offset of block 56 */ 0x00390000l, /* start offset of block 57 */ 0x003a0000l, /* start offset of block 58 */ 0x003b0000l, /* start offset of block 59 */ 0x003c0000l, /* start offset of block 60 */ 0x003d0000l, /* start offset of block 61 */ 0x003e0000l, /* start offset of block 62 */ 0x003f0000l, /* start offset of block 63 */ }; #endif /* use_m58lw064a */ #define num_blocks (sizeof(blockoffset)/sizeof(blockoffset[0])) /* burst configuration register definitions */ #define flash_bcr_mode_mask 0x00008000l #define flash_bcr_xlat_mask 0x00007800l #define flash_bcr_ylat_mask 0x00000200l #define flash_bcr_length_mask 0x00000007l /******************************************************************************* static prototypes the following function is only needed in this module.
AN1270 - application note 12/28 *******************************************************************************/ static unsigned int flashwrite( unsigned long uloff, unsigned int uval ); /******************************************************************************* function: unsigned int flashwrite( unsigned long uloff, unsigned int uval ) arguments: uloff is double-word offset in the flash to write to. uval is the value to be written returns: uval description: this function is used to write a word to the flash. on many microprocessor systems a macro can be used instead, increasing the speed of the flash routines. for example: #define flashwrite( uloff, uval ) ( base_addr[uloff] = (unsigned int) uval ) a function is used here instead to allow the user to expand it if necessary. the function is made to return uval so that it is compatible with the macro. pseudo code: step 1: write uval to the word offset in the flash step 2: return uval *******************************************************************************/ static unsigned int flashwrite( unsigned long uloff, unsigned int uval ) { /* step1, 2: write uval to the word offset in flash and return it */ return base_addr[uloff] = uval; } /******************************************************************************* function: unsigned int flashread( unsigned long uloff ) arguments: uloff is the word offset into the flash to read from. returns: the unsigned int at the word offset. description: this function is used to read a word from the flash. on many microprocessor systems a macro can be used instead, increasing the speed of the flash routines. for example: #define flashread( uloff ) ( base_addr[uloff] ) a function is used here instead to allow the user to expand it if necessary. pseudo code: step 1: return the value at word offset uloff *******************************************************************************/ unsigned int flashread( unsigned long uloff ) { /* step 1 return the value at word offset uloff */ return base_addr[uloff]; } /******************************************************************************* function: void flashreadreset( void ) arguments: none return value: none description: this function places the flash in the read array mode described in the data sheet. in this mode the flash can be read as normal memory. all of the other functions leave the flash in the read array mode so this is not strictly necessary. it is provided for completeness.
13/28 AN1270 - application note pseudo code: step 1: write command sequence (see instructions table of the data sheet) *******************************************************************************/ void flashreadreset( void ) { /* step 1: write command sequence */ flashwrite( any_addr, 0x00ff ); } /******************************************************************************* function: int flashautoselect( int ifunc ) arguments: ifunc should be set either to the read signature values or to the block number. the header file defines the values for reading the signature. note: the first block is block 0 return value: when ifunc is >= 0 the function returns flash_block_protected (01h) if the block is protected and flash_block_unprotected (00h) if it is unprotected. see the auto select command in the data sheet for further information. when ifunc is flash_read_manufacturer (-2) the function returns the manufacturers code. the manufacturer code for st is 0020h. when ifunc is flash_read_device_code (-1) the function returns the device code. the device codes for the parts are: m58lw064a 0x0017 when ifunc is invalid the function returns flash_block_invalid (-5) description: this function can be used to read the electronic signature of the device or the manufacturer code. it can also be used to read the protection status of a block. pseudo code: step 1: send the read electronic signature instruction step 2: read the required function from the device step 3: return the device to read array mode *******************************************************************************/ int flashautoselect( int ifunc ) { int iretval; /* holds the return value */ /* step 1: send the read electronic signature instruction */ flashwrite( any_addr, 0x0090 ); /* step 2: read the required function */ if( ifunc == flash_read_manufacturer ) iretval = flashread( 0x00000000l ); /* a1 = a2 = 0 */ else if( ifunc == flash_read_device_code ) iretval = flashread( 0x00000001l ); /* a1 = 1, a2 = 0 */ else if( (ifunc >= 0) && (ifunc < num_blocks) ) iretval = flashread( blockoffset[ifunc] + 0x00000002l ); /* a1 = 0, a2 = 1 */ else iretval = flash_block_invalid; /* step 3: return to read array mode */ flashwrite( any_addr, 0x00ff );
AN1270 - application note 14/28 return iretval; } /******************************************************************************* function: int flashreadcfi( int icfifunc, unsigned int *ucfivalue ) arguments: icfifunc is set to the offset of the cfi parameter to be read. the cfi value read from offset icfifunc is passed back to the calling function by *ucfivalue. return value: on success returns flash_success (-1) or if the cfi cannot be identified by reading the chracters qry from locations 0x10, 0x11 and 0x12, the function returns flash_cfi_fail (-22) description: this function checks that the flash cfi is present and operable, then reads the cfi value at the specified offset. the cfi value requested is then passed back to the calling function. pseudo code: step 1: send the read cfi instruction step 2: check that the cfi interface is operable step 3: if cfi is operable read the required cfi value step 4: return the flash to read array mode *******************************************************************************/ int flashreadcfi( int icfifunc, unsigned int *ucfivalue ) { int iretval = flash_success; /* holds the return value */ unsigned long ulcfiaddr; /* holds cfi address */ /* step 1: send the read cfi instruction */ flashwrite( any_addr, 0x0098 ); /* step 2: check that the cfi interface is operable */ if( ((flashread( 0x00000010l ) & 0x00ff) != 0x0051) || ((flashread( 0x00000011l ) & 0x00ff) != 0x0052) || ((flashread( 0x00000012l ) & 0x00ff) != 0x0059) ) iretval=flash_cfi_fail; else { /* step 3: read the required cfi */ ulcfiaddr = (unsigned long)icfifunc; *ucfivalue = flashread( ulcfiaddr & 0x000000ffl ); } /* step 4: return to read array mode */ flashwrite( any_addr, 0x00ff ); return iretval; } /******************************************************************************* function: int flashblockerase( unsigned char ucblock ) arguments: ucblock is the number of the block to be erased. return value: the function returns the following conditions: flash_success (-1) flash_block_invalid (-5) flash_wrong_type (-8) flash_block_failed_erase (-9) flash_protected (-11) flash_vpp_invalid (-13) description: this function can be used to erase the block specified in ucblock. the function checks that the block is valid before issuing the erase
15/28 AN1270 - application note command. once the erase has completed the function checks the status register for errors. any errors are returned, otherwise flash_success is returned. pseudo code: step 1: check for correct flash type step 2: check that the block is valid step 3: check to see if the block is protected step 4: issue erase command step 5: wait until program/erase controller is ready step 6: check for any errors step 7: clear status register and return to read array mode step 8: return error condition *******************************************************************************/ int flashblockerase( unsigned char ucblock ) { int iretval = flash_success; /* holds return value: optimistic initially! */ unsigned int ustatus; /* holds the status register reads */ /* step 1: check for correct flash type */ if( !(flashautoselect( flash_read_manufacturer ) == manufacturer_st) || !(flashautoselect( flash_read_device_code ) == expected_device ) ) return flash_wrong_type; /* step 2: check that the block is valid */ if( ucblock >= num_blocks ) return flash_block_invalid; /* step 3: check to see if the block is protected */ if ( flashautoselect( (int)ucblock ) == flash_block_protected) return flash_protected; /* step 4: issue erase command */ flashwrite( any_addr, 0x0050l ); /* clear status register */ /* note ! csr also clears bit 1 bps as well as bits 3, 4 and 5 */ flashwrite( any_addr, 0x0020 ); /* 1st cycle */ flashwrite( blockoffset[ucblock], 0x00d0 ); /* 2nd cycle */ /* step 5: wait until program/erase controller is ready */ /* timeout! */ do ustatus = flashread(any_addr); while( (ustatus & 0x0080) == 0x0000 ); /* step 6: check for any errors */ if( ustatus & 0x0008 ) iretval = flash_vpp_invalid; else if( ustatus & 0x0020 ) iretval = flash_block_failed_erase; else if( ustatus & 0x0002 ) iretval = flash_protected; else if( ustatus & 0x0010 ) iretval = flash_block_failed_erase; /* step 7: clear status register and return to read array mode */ flashwrite( any_addr, 0x0050l ); /* clear status register */ /* note ! csr also clears bit 1 bps as well as bits 3, 4 and 5 */ flashwrite( any_addr, 0x00ff ); /* read array command */
AN1270 - application note 16/28 /* step 8: return error condition */ return iretval; } /******************************************************************************* function: int flashchiperase( int *iresults ) arguments: iresults is a pointer to an array where the results will be stored. if iresults == null then no results are stored. return value: the function returns the following conditions: flash_success (-1) flash_wrong_type (-8) flash_erase_fail (-14) if flash_success or flash_wrong_type are returned then results is left unchanged. if flash_erase_fail is returned then results will be filled with the error conditions for each block. the possible error conditions are: flash_success (-1) flash_protected (-11) flash_vpp_invalid (-13) flash_block_failed_erase (-14) description: the function can be used to erase the whole flash chip. each block is erased in turn. the function only returns when all of the blocks have been erased or have generated an error, except if the flash_vpp_invalid is encountered, in which case the function aborts and reports all remaining blocks as having flash_vpp_invalid. if vpp is invalid for one block then it follows that it will be invalid for subsequent blocks (battery failure?). pseudo code: step 1: check for correct flash type step 2: for each block step 3: send block erase command step 4: register the errors in the array step 5: if flash_vpp_invalid returned fill rest of results array & abort step 6: return error condition *******************************************************************************/ int flashchiperase( int *iresults ) { unsigned char uccurblock; /* used to track the current block in a range */ int iretval = flash_success; /* return value: initially optimistic */ int ierror; /* holds the latest error */ /* step 1: check for correct flash type */ if( !(flashautoselect( flash_read_manufacturer ) == manufacturer_st) || !(flashautoselect( flash_read_device_code ) == expected_device ) ) return flash_wrong_type; /* step 2: for each block */ for( uccurblock = 0; uccurblock < num_blocks; uccurblock++ ) { /* step 3: send block erase command */ ierror = flashblockerase( uccurblock ); if( ierror != flash_success ) iretval = flash_erase_fail; /* step 4: register the errors in the array */ if( iresults != null ) iresults[uccurblock] = ierror; /* step 5: if flash_vpp_invalid returned fill rest of results array & abort */
17/28 AN1270 - application note if( ierror == flash_vpp_invalid ) { if( iresults != null ) while( ++uccurblock < num_blocks ) /* on remaining blocks */ iresults[uccurblock] = ierror; /* fill in vpp error */ /* the for() loop will now terminate since uccurblock == num_blocks */ } } /* step 6: return error condition */ return iretval; } /******************************************************************************* function: int flashprogram( unsigned long uloff, size_t numwords, void *array ) arguments: uloff is the word offset into the flash to be programmed numwords holds the number of words in the array. array is a pointer to the array to be programmed. return value: the function returns the following conditions: flash_success (-1) successful operation flash_program_fail (-6) failure not covered below flash_offset_out_of_range (-7) program range outside device flash_wrong_type (-8) wrong flash fitted flash_protected (-11) block to program is protected flash_vpp_invalid (-13) vpp is not valid description: this function is used to program an array into the flash. it does not erase the flash first and will fail if the block(s) are not erased first. note that the function always programs all addresses within the same page by issuing a single program command, as is required by the device architecture. once the program command has completed the function checks the status register for errors. any errors are returned without any further attempts to program other addresses of the device. the function returns flash_success when all addresses have successfully been programmed. pseudo code: step 1: check for correct flash type step 2: check the offset range is valid step 3: while there is more to be programmed step 4: determine limits of current set of 4 pages step 5: program within the next set of 4 pages step 6: wait until the program/erase controller is ready step 7: check for any errors step 8: clear status register and return to read array mode step 9: return the error condition *******************************************************************************/ int flashprogram( unsigned long uloff, size_t numwords, void *array ) { unsigned int *uarraypointer; /* use an unsigned int to access the array */ unsigned long ullastoff; /* holds the last offset to be programmed */ unsigned long ulendset; /* holds the end of the current set of pages */ unsigned int ustatus; /* holds the status register reads */ unsigned int unumwords; /* number of words to be programmmed */ int iretval = flash_success; /* return value: initially optimistic */ /* step 1: check that the flash is of the correct type */ if( !(flashautoselect( flash_read_manufacturer ) == manufacturer_st) || !(flashautoselect( flash_read_device_code ) == expected_device ) ) return flash_wrong_type;
AN1270 - application note 18/28 /* step 2: check the offset range is valid */ ullastoff = uloff + numwords - 1; if( ullastoff >= flash_size ) return flash_offset_out_of_range; /* step 3: while there is more to be programmed */ uarraypointer = (unsigned int *)array; while( uloff <= ullastoff && iretval == flash_success ) { /* step 4: determine limits of current set of 4 pages */ ulendset = 16l * (uloff / 16l) + 15l; if( ulendset > ullastoff ) ulendset = ullastoff; unumwords = ulendset - uloff + 1; /* number of words to be programmed */ /* step 5: program within the next set of 4 pages */ flashwrite( any_addr, 0x0050l ); /* clear status register */ /* note ! csr also clears bit 1 bps as well as bits 3, 4 and 5 */ flashwrite( uloff, 0x00e8 ); /* program set-up */ flashwrite( uloff, unumwords - 1 ); /* number of words */ while( uloff <= ulendset ) flashwrite( uloff++, *(uarraypointer++) ); /* program value */ flashwrite( any_addr, 0x00d0 ); /* confirm program */ /* step 6: wait until program/erase controller is ready */ /* timeout! */ do ustatus = flashread(any_addr); while( (ustatus & 0x0080) == 0x0000 ); /* step 7: check for any errors */ if( ustatus & 0x0008 ) iretval = flash_vpp_invalid; else if( ustatus & 0x0002 ) iretval = flash_protected; else if( ustatus & 0x0020 ) iretval = flash_program_fail; else if( ustatus & 0x0010 ) iretval = flash_program_fail; } /* step 8: clear status register and return to read array mode */ flashwrite( any_addr, 0x0050 ); /* clear status register */ /* note ! csr also clears bit 1 bps as well as bits 3, 4 and 5 */ flashwrite( any_addr, 0x00ff ); /* read array command */ /* step 9: return the error condition */ return iretval; } /******************************************************************************* function: int flashblockprotect( unsigned char ucblock ) arguments: ucblock holds the block number to protect return value: the function returns the following conditions: flash_success (-1) flash_block_invalid (-5) flash_wrong_type (-8) flash_protected (-11)
19/28 AN1270 - application note flash_vpp_invalid (-13) flash_protect_fail (-18) description: this function protects a block selected by ucblock but only if that particular block is unprotected and valid. the block protect command is then written and then checked to ensure that it was successful. pseudo code: step 1: check for correct flash type step 2: check to see if the block number ucblock is valid step 3: check if the block really needs protecting as it may already be protected step 4: protect the block step 5: wait until program/erase controller is ready step 6: check for any errors step 7: clear status register and return to read array mode step 8: read the block ucblock to check protection status *******************************************************************************/ int flashblockprotect( unsigned char ucblock ) { int iretval; /* store result */ unsigned int ustatus; /* step 1: check for correct flash type */ if( !(flashautoselect( flash_read_manufacturer ) == manufacturer_st) || !(flashautoselect( flash_read_device_code ) == expected_device ) ) return flash_wrong_type; /* step 2: check to see if the block number ucblock is valid */ iretval = flashautoselect( (int)ucblock ); if (iretval == flash_block_invalid) return flash_block_invalid; /* step 3: check if the block really needs protecting as it may already be protected */ else if( iretval == flash_block_protected ) return flash_protected; /* step 4: protect the block */ flashwrite(blockoffset[ucblock], 0x0060); flashwrite(blockoffset[ucblock], 0x0001); /* step 5: wait until program/erase controller is ready */ do ustatus = flashread(any_addr); /* timeout! */ while( (ustatus&0x0080) == 0x0000 ); /* step 6: check for any errors */ if( ustatus & 0x0008 ) iretval = flash_vpp_invalid; else if( ustatus & 0x0020 ) iretval = flash_protect_fail; else if( ustatus & 0x0002 ) iretval = flash_protect_fail; else if( ustatus & 0x0010 ) iretval = flash_protect_fail; else iretval = flash_success;
AN1270 - application note 20/28 /* step 7: clear status register and return to read array mode */ flashwrite( any_addr, 0x0050 ); /* clear status register */ /* note ! csr also clears b1 bps as well as b3,4 and 5 */ flashwrite( any_addr, 0x00ff ); /* read array command */ /* step 8: read the block ucblock to check protection status */ if(iretval != flash_success) return iretval; else if (flashautoselect( (int)ucblock ) != flash_block_protected) return flash_protect_fail; else return flash_success; } /******************************************************************************* function: int flashchipunprotect( void ) arguments: none return value: the function returns the following conditions: flash_success (-1) flash_block_invalid (-5) flash_wrong_type (-8) flash_unprotect_fail (-16) flash_unprotected (-10) flash_vpp_invalid (-13) description: this function unprotects a block selected by ucblock but only if that particular block is protected and valid. the block unprotect command is then written and then checked to ensure that it was successful. pseudo code: step 1: check for correct flash type step 2: unprotect the flash memory step 3: wait until program/erase controller is ready step 4: check for any errors step 5: clear status register and return to read array mode *******************************************************************************/ int flashunprotect( void ) { int iretval; /* store result */ unsigned int ustatus; /* step 1: check for correct flash type */ if( !(flashautoselect( flash_read_manufacturer ) == manufacturer_st) || !(flashautoselect( flash_read_device_code ) == expected_device ) ) return flash_wrong_type; /* step 2: unprotect the flash memory */ flashwrite( any_addr, 0x0060 ); flashwrite( any_addr, 0x00d0 ); /* step 3: wait until program/erase controller is ready */ do ustatus = flashread(any_addr); /* timeout! */ while( (ustatus&0x0080) == 0x0000 ); /* step 4: check for any errors */ if( ustatus & 0x0008 ) iretval = flash_vpp_invalid; else if( ustatus & 0x0020 )
21/28 AN1270 - application note iretval = flash_unprotect_fail; else if( ustatus & 0x0002 ) iretval = flash_unprotect_fail; else if( ustatus & 0x0010 ) iretval = flash_unprotect_fail; else iretval = flash_success; /* step 5: clear status register and return to read array mode */ flashwrite( any_addr, 0x0050 ); /* clear status register */ /* note ! csr also clears b1 bps as well as b3,4 and 5 */ flashwrite( any_addr, 0x00ff ); /* read array command */ return iretval; } /******************************************************************************* function: int flashsetburstconfig( unsigned long ulburstconfig ) arguments: ulburstconfig specifies the burst configuration register setting. the user should only set this value by bit-wise oring of the bit mask definitions provided in the header file c1270_16.h. return value: the function returns the following conditions: flash_success (-1) flash_wrong_type (-8) flash_config_invalid (-23) description: this function changes the configuration of read accesses to the flash memory. the function first checks that the configuration specified by argument ulburstconfig is valid for the flash fitted. then it issues the command required to change the burst configuration of the device. notes: after the burst configuration register is modified by this function, read accesses from the device will only be successful if the bus configuration of the microprocessor is set up accordingly. the y-latency bit of the burst configuration register has a different meaning depending on the x-latency. so there is an extra check to adjust the y-latency bit of the burst configuration register based on the value specified by the argument ulburstconfig. pseudo code: step 1: check for correct flash type step 2: check that the specified burst configuration is valid step 3: adjust the burst configuration register y-latency step 4: issue the set burst configuration register command *******************************************************************************/ int flashsetburstconfig( unsigned long ulburstconfig ) { unsigned long ulblen; /* burst length */ unsigned long ulxlat; /* burst x-latency */ /* step 1: check for correct flash type */ if( !(flashautoselect( flash_read_manufacturer ) == manufacturer_st) || !(flashautoselect( flash_read_device_code ) == expected_device ) ) return flash_wrong_type; /* step 2: check that the specified burst configuration is valid */ if( ulburstconfig & flash_bcr_mode_mask == flash_bcr_asynchronous ) ; /* no configuration checks needed for asynchronous mode */ else /* synchronous mode: check the burst length, x-latency and y-latency */ {
AN1270 - application note 22/28 /* check that the burst length setting is valid */ ulblen = ulburstconfig & flash_bcr_length_mask; if( (ulblen != flash_bcr_length_1) && (ulblen != flash_bcr_length_2) && (ulblen != flash_bcr_length_4) && (ulblen != flash_bcr_length_8) && (ulblen != flash_bcr_continuous) ) return flash_config_invalid; /* check that the x-latency setting is valid */ ulxlat = ulburstconfig & flash_bcr_xlat_mask; switch( ulxlat ) { case flash_bcr_xlat_8: case flash_bcr_xlat_9: case flash_bcr_xlat_12: /* no other checks needed for these values of x-latency */ break; case flash_bcr_xlat_7: case flash_bcr_xlat_10: case flash_bcr_xlat_11: /* need to make sure that the burst length is continuous */ if( ulblen != flash_bcr_continuous ) return flash_config_invalid; break; case flash_bcr_xlat_13: case flash_bcr_xlat_15: /* need to make sure that the y-latency setting is valid */ if( ulburstconfig & flash_bcr_ylat_mask == flash_bcr_ylat_1 ) return flash_config_invalid; else /* step 3: adjust the burst configuration register y-latency */ ulburstconfig = ulburstconfig & ~flash_bcr_ylat_mask; break; default: return flash_config_invalid; } } /* step 4: issue the set burst configuration register command */ flashwrite( ulburstconfig << 1, 0x0060 ); /* first cycle */ flashwrite( ulburstconfig << 1, 0x0003 ); /* second cycle */ return flash_success; } /******************************************************************************* function: char *flasherrorstr( int ierrnum ); arguments: ierrnum is the error number returned from another flash routine return value: a pointer to a string with the error message description: this function is used to generate a text string describing the error from the flash. call with the return value from another flash routine. pseudo code: step 1: check the error message range. step 2: return the correct string. *******************************************************************************/ char *flasherrorstr( int ierrnum ) { static char *str[] = { flash success, flash poll failure, flash too many blocks,
23/28 AN1270 - application note mpu is too slow to erase all the blocks, flash block selected is invalid, flash program failure, flash address offset out of range, flash is wrong type, flash block failed erase, flash is unprotected, flash is protected, flash function not supported, flash vpp invalid, flash erase fail, flash toggle flow chart failure, flash unprotect failed, flash bank invalid, flash protect failed, flash overlay command failed, flash overlay disabled already, flash overlay enabled already, flash cfi failure, flash configuration invalid }; /* step 1: check the error message range */ ierrnum = -ierrnum - 1; /* all errors are negative: make +ve & adjust */ if( ierrnum < 0 || ierrnum >= sizeof(str)/sizeof(str[0])) /* check range */ return unknown error\n; /* step 2: return the correct string */ else return str[ierrnum]; } /******************************************************************************* list of errors and return values, explanations and help. ******************************************************************************** return name: flash_success return value: -1 description: this value indicates that the flash command has executed correctly. ******************************************************************************** error name: flash_poll_fail notes: applies to m29 series flash only. this error condition should not occur when using this library. return value: -2 description: the program/erase controller algorithm has not managed to complete the command operation successfully. this may be because the device is damaged solution: try the command again. if it fails a second time then it is likely that the device will need to be replaced. ******************************************************************************** error name: flash_too_many_blocks notes: applies to m29 series flash only. this error condition should not occur when using this library. return value: -3 description: the user has chosen to erase more blocks than the device has. this may be because the array of blocks to erase contains the same block
AN1270 - application note 24/28 more than once. solutions: check that the program is trying to erase valid blocks. the device will only have num_blocks blocks (defined at the top of the file). also check that the same block has not been added twice or more to the array. ******************************************************************************** error name: flash_mpu_too_slow notes: applies to m29 series flash only. this error condition should not occur when using this library. return value: -4 description: the mpu has not managed to write all of the selected blocks to the device before the timeout period expired. see block erase command section of the data sheet for details. solutions: if this occurs occasionally then it may be because an interrupt is occuring between writing the blocks to be erased. search for dsi! in the code and disable interrupts during the time critical sections. if this error condition always occurs then it may be time for a faster microprocessor, a better optimising c compiler or, worse still, learn assembly. the immediate solution is to only erase one block at a time. disable the test (by #defineing out the code) and always call the function with one block at a time. ******************************************************************************** error name: flash_block_invalid return value: -5 description: a request for an invalid block has been made. valid blocks number from 0 to num_blocks-1. solution: check that the block is in the valid range. ******************************************************************************** error name: flash_program_fail return value: -6 description: the programmed value has not been programmed correctly. solutions: make sure that the block containing the value was erased before programming. try erasing the block and re-programming the value. if it fails again then the device may be faulty. ******************************************************************************** error name: flash_offset_out_of_range return value: -7 description: the address offset given is out of the range of the device. solution: check the address offset is in the valid range. ******************************************************************************** error name: flash_wrong_type return value: -8 description: the source code has been used to access the wrong type of flash. solutions: use a different flash chip with the target hardware or contact stmicroelectronics for a different source code library. ******************************************************************************** error name: flash_block_failed_erase return value: -9 description: the previous erase to this block has not managed to successfully erase the block. solution: check that vpp is not floating. try erasing the block again. if this fails, the device may be faulty and need replacing. ********************************************************************************
25/28 AN1270 - application note return name: flash_unprotected return value: -10 description: the user has requested to unprotect a block that is already unprotected. this is just a warning to the user that their operation did not make any changes and was not necessary. ******************************************************************************** error name: flash_protected return value: -11 description: the user has attempted to erase, program or protect a block of the flash that is protected. the operation failed because the block was protected. solutions: choose another (unprotected) block for erasing or programming. alternatively change the block protection status of the current block. (see datasheet for more details). in the case of the user protecting a block that is already protected, this warning notifies the user that the command had no effect. ******************************************************************************** return name: flash_function_not_supported notes: this error condition should not occur when using this library. return value: -12 description: the user has attempted to make use of functionality not available on this flash device (and thus not provided by the software drivers). this is simply a warning to the user. ******************************************************************************** error name: flash_vpp_invalid notes: applies to m28 (and m58) series flash only. return value: -13 description: a program or a block erase has been attempted with the vpp supply voltage outside the allowed ranges. this command had no effect since an invalid vpp has the effect of protecting the whole of the flash device. solution: the (hardware) configuration of vpp will need to be modified to make programming or erasing the device possible. ******************************************************************************** error name: flash_erase_fail return value: -14 description: this indicates that the previous erasure of the whole device has failed. solution: investigate this failure further by attempting to erase each block individually. if erasing a single block still causes failure, then the flash sadly needs replacing. ******************************************************************************** error name: flash_toggle_fail notes: applies to m29 series flash only. this error condition should not occur when using this library. return value: -15 description: the program/erase controller algorithm has not managed to complete the command operation successfully. this may be because the device is damaged. solution: try the command again. if it fails a second time then it is likely that the device will need to be replaced. ******************************************************************************** error name: flash_unprotect_fail return value: -16
AN1270 - application note 26/28 description: this error return value indicates that the chip unprotect command was unsuccessful. solution: check that vpp is not floating but is tied to a valid voltage. try the command again. if it fails a second time then it is likely that the device cannot be unprotected and will need to be replaced. ******************************************************************************** error name: flash_bank_invalid notes: this applies to m59drxxx series flash only. this error condition should not occur when using this library. return value: -17 description: this error return value indicates that a bank does not exist. ******************************************************************************** error name: flash_protect_fail return value: -18 description: this error return value indicates that a block protect command was unsuccessful. solution: check that vpp is not floating but is tied to a valid voltage. try the command again. if it fails a second time then the block cannot be protected and it may be necessary to replace the device. ******************************************************************************** error name: flash_overlay_fail notes: this applies only to flash memories with overlay blocks. this error condition should not occur when using this library. return value: -19 description: this error indicates that any overlay block associated function has failed. ******************************************************************************** error name: flash_overlay_disabled notes: this applies only to flash memories with overlay blocks. this error condition should not occur when using this library. return value: -20 description: this error informs the user that a overlayblockdisable command was not neccesary because the overlay block was already disabled. ******************************************************************************** error name: flash_overlay_enabled notes: this applies only to flash memories with overlay blocks. this error condition should not occur when using this library. return value: -21 description: this error informs the user that a overlayblockenable command was not necessary because the overlay block was already enabled. ******************************************************************************** error name: flash_cfi_fail return value: -22 description: this error return value indicates that a cfi read was unsuccessful solution: try an autoselect command; if this fails it is likely that the device is faulty or the interface to the flash is not correct. ******************************************************************************** error name: flash_config_invalid
27/28 AN1270 - application note return value: -23 description: this error return value indicates that the specified configuration is not valid or not supported for the device being used. solution: check the specified configuration. identify a configuration supported by the device and call the function again with this new setting. *******************************************************************************/
AN1270 - application note 28/28 if you have any questions or suggestion concerning the matters raised in this document please send them to the following electronic mail address: ask.memory@st.com (for general enquiries) please remember to include your name, company, location, telephone number and fax number. information furnished is believed to be accurate and reliable. however, stmicroelectronics assumes no responsibility for the co nsequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of stmicroelectronics. specifications mentioned in this publicati on are subject to change without notice. this publication supersedes and replaces all information previously supplied. stmicroelectronics prod ucts are not authorized for use as critical components in life support devices or systems without express written approval of stmicroelectro nics. the st logo is registered trademark of stmicroelectronics a 2001 stmicroelectronics - all rights reserved all other names are the property of their respective owners. stmicroelectronics group of companies australia - brazil - china - finland - france - germany - hong kong - india - italy - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - u.s.a. http://www.st.com


▲Up To Search▲   

 
Price & Availability of AN1270

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X